feat: passthrough fallback when Clap parse fails + review fixes#200
Open
guillaumedeslandes wants to merge 6 commits intortk-ai:masterfrom
Open
feat: passthrough fallback when Clap parse fails + review fixes#200guillaumedeslandes wants to merge 6 commits intortk-ai:masterfrom
guillaumedeslandes wants to merge 6 commits intortk-ai:masterfrom
Conversation
Collaborator
|
Tested locally — solid approach, needs rebase + 2 fixes before merge. Testing results:
Must fix:
Nice to have (non-blocking):
This will fix #204, #228, #229 and any future unknown-flag issues globally. Great work! |
When RTK cannot parse a command (e.g. `rtk git -C /path status`), instead of exiting with error code 2, it now falls back to running the raw command directly. This keeps developer workflows unbroken. - Replace Cli::parse() with try_parse() + run_fallback() - Add parse_failures SQLite table for failure analytics - Add `rtk gain --failures` / `-F` to view failure log - Fallback preserves stdin/stdout/stderr via Stdio::inherit() - --help and --version still work normally Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When Clap fails to parse a meta-command like `rtk gain --badtypo`, show the Clap error directly instead of trying to execute `gain` as a binary from $PATH. Adds RTK_META_COMMANDS constant listing gain, discover, learn, init, config, proxy, hook-audit, cc-economics. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
TimedExecution::start() was called after the command finished, so all fallback commands showed ~0ms in rtk gain --history. Now the timer captures actual command runtime. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The parse_failures table was never cleaned up because only record() called cleanup_old(). Now parse failures also trigger 90-day retention cleanup. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Clap errors may contain terminal color codes. Strip them with utils::strip_ansi() before storing in the parse_failures table to avoid garbled output and wasted space. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
0c07be2 to
8142173
Compare
- cargo test check now matches RTK's filtered output format ("passed")
in addition to raw "test result:" and "FAILURES"
- Fix undefined `skip` calls to use existing `skip_test` function
with proper (name, reason) arguments
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Author
@pszymkowiak Rebased and implemented requested changes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
git -C /path status), RTK executes the raw command instead of erroring outgain,discover,learn,init,config,proxy,hook-audit,cc-economics) from falling through to raw$PATHexecution — bad flags likertk gain --badtyposhow the Clap error directlyrtk gain --history(was showing ~0ms)record_parse_failure()(parse_failures table was never cleaned up)cargo testassertion now matches RTK's filtered output, fix undefinedskip→skip_testcallsTest plan
cargo test)bash scripts/test-all.sh)rtk gain --badtyposhows Clap error (not "command not found")rtk git -C /path statusfalls back to rawgit -C /path statusrtk --helpandrtk --versionstill work normallyFixes #204, #228, #229
🤖 Generated with Claude Code